package service;

import crotrol.NewsCategoryControl;
import crotrol.NewsControl;
import entity.NewsCategory;

public class NewsCategoryServiceImpl implements NewsCategoryService {
    @Override
    public boolean deleteNewsCategory(NewsCategory newsCategory) {
        NewsControl newsControl = new NewsControl();
        int i = newsControl.getNewsCount(newsCategory);
        if (i>0){
            System.out.println("删除失败");
            return false;
        }else {
            NewsCategoryControl ncc= new NewsCategoryControl();
            ncc.deleteCategory(newsCategory);
            return true;
        }
    }

    public static void main(String[] args) {
        NewsCategoryServiceImpl ncsi = new NewsCategoryServiceImpl();
        NewsCategory newsCategory = new NewsCategory();
        newsCategory.setId(7);
        ncsi.deleteNewsCategory(newsCategory);
    }
}
